package com.example.fireassistant_server.entity;

import lombok.Data;
import org.hibernate.annotations.Fetch;
import org.hibernate.annotations.FetchMode;

import javax.persistence.*;
import java.math.BigDecimal;
import java.util.List;
import java.util.Set;

@Table(name = "hydrant")
@Entity
@Data
public class FireHydrant extends MarkerEntity{

    private BigDecimal latitude;

    private BigDecimal longitude;

    private String name;

    //消火栓状态
    private Boolean status = true;

    //表示消火栓综合情况
    private int score = 100;

    @Column(name = "flow_rate")
    private String flowRate;

    private String description;

    @ManyToOne
    @JoinColumn(name = "user_id", referencedColumnName = "id")
    private User user;

    @ManyToMany(fetch = FetchType.EAGER)
    @Fetch(FetchMode.SUBSELECT)
    @JoinTable(name = "hydrant_file", joinColumns = @JoinColumn(name = "hydrant_id", referencedColumnName = "id"), inverseJoinColumns = @JoinColumn(name = "file_id", referencedColumnName = "id"))
    private List<File> Files;

}
